#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent, QImage* image) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    if( image ) {
        img = image;
        imgLabel = new ImageLabel( ui->statusBar, image );
        ui->verticalLayout->addWidget( imgLabel );
    }
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::resizeEvent(QResizeEvent *event)
{    
    QRect geometry (ui->centralWidget->geometry());

    if( geometry.width() > this->img->width() ) {
        geometry.setWidth( this->img->width() );
    }

    if( geometry.height() > this->img->height() ) {
        geometry.setHeight( this->img->height() );
    }

    ui->verticalLayout->setGeometry( geometry );
    ui->verticalLayoutWidget->setGeometry( geometry );
    imgLabel->setGeometry( geometry );
}
